package initialize

import (
	"go-fiber-ip2region/router"

	_ "go-fiber-ip2region/docs"

	fiberSwagger "github.com/arsmn/fiber-swagger/v2"
	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/cors"
	"github.com/gofiber/fiber/v2/middleware/csrf"
)

func Routers() *fiber.App {
	app := fiber.New()
	// 开启crsf防护
	app.Use(csrf.New())
	// 开启跨域
	app.Use(cors.New())

	app.Get("/swagger/*", fiberSwagger.HandlerDefault)

	PrivateGroup := app.Group("")

	// 获取路由组实例
	versionRouter := router.RouterGroupApp.Version
	ipInfoRouter := router.RouterGroupApp.IpInfo
	{
		versionRouter.InitVersionGetRouter(PrivateGroup)
		ipInfoRouter.InitIpInfoRouter(PrivateGroup)

	}

	return app
}
